package edu.hz.service.impl;

import edu.hz.dao.DonationMapper;
import edu.hz.model.dto.CreateDonationDto;
import edu.hz.model.entity.DonationEntity;
import edu.hz.service.DonationService;
import edu.hz.util.web.ApiResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class DonationServiceImpl implements DonationService {

    @Resource
    private DonationMapper donationMapper;

    @Override
    public ApiResponse<Integer> createDonation(CreateDonationDto createDonationDto) {
        DonationEntity donation = new DonationEntity();
        donation.setName(createDonationDto.getName());
        donation.setStart(createDonationDto.getStart());
        donation.setEnd(createDonationDto.getEnd());
        donation.setNeedMoney(createDonationDto.getNeedMoney());
        donation.setAuthor(createDonationDto.getAuthor());
        donation.setProfile(createDonationDto.getProfile());
        donation.setContent(createDonationDto.getContent());
        donation.setIsTop(createDonationDto.getIsTop());

        return ApiResponse.success(donationMapper.insertDonation(donation));
    }

}
